package dolf.window;

import java.util.HashMap;


public class SystemMessagesHandler {
	private static SystemMessagesHandler instance = new SystemMessagesHandler();
	
	private java.util.ResourceBundle messages;
	private java.util.Locale currLocale;
	
	private HashMap<String, java.util.ResourceBundle> map = new HashMap<String, java.util.ResourceBundle>();
	
	private SystemMessagesHandler() {
		initMessages();
	}
	
	public static SystemMessagesHandler getInstance() {
		return instance;
	}
	
	public void initMessages() {
		currLocale = new java.util.Locale(ConfigurationHandler.getInstance().getProperty("lang"));
		messages = java.util.ResourceBundle.getBundle("dolf.lang.lang", currLocale);
	}

	public java.util.ResourceBundle getMessages() {
		if (messages == null) initMessages();
		return messages;
	}
	
	public java.util.ResourceBundle getMessages(String filename) {
		if (map.containsKey(filename)) return map.get(filename);
		//else
		java.util.ResourceBundle m;
		m = java.util.ResourceBundle.getBundle(filename, currLocale);
		map.put(filename, m);
		return m;
	}
}
